package com.yanqu.road.logic.activity.foxcard.game.spell;

import com.yanqu.road.entity.activity.foxcard.FoxEffectCard;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;

import java.math.BigDecimal;

/**
 * 获得小丑牌总售价
 * 0|金额上限
 */
public class FoxCardSpellUse5 extends FoxCardSpellUseBase {
    @Override
    protected boolean spellUse(FoxCardGameLogic gameLogic) {
        int addLimit = spellConfig.getParamList().get(1);

        int goldChange = 0;
        for (FoxEffectCard effectCard : gameLogic.getGameData().getEffectCards()) {
            int price = effectCard.getPrice();
            int goldAdd = BigDecimal.valueOf(price).multiply(BigDecimal.valueOf(gameLogic.getConfig().getSalePriceOff()).divide(BigDecimal.valueOf(1000))).intValue();
            //最低1金币
            if (goldAdd < 1) {
                goldAdd = 1;
            }
            goldChange+=goldAdd;
        }

        if (goldChange > addLimit) {
            goldChange = addLimit;
        }
        gameLogic.goldChange(goldChange, null, null, eFoxCardTriggerType.REMOVE);
        return true;
    }
}
